package com.sinosoft.dsp.platform.services;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.NoneScoped;

import com.sinosoft.builder.templates.concept.TagElementType;
import com.sinosoft.dsp.system.core.log.Log;
import com.sinosoft.dsp.system.utils.Const;

@ManagedBean(name = "systemAttributeService")
@NoneScoped
public class SystemAttributeService {
	private static final Log log = Log.getLog(SystemAttributeService.class
			.getName());

	@ManagedProperty(value = "#{codeSetService}")
	private CodeSetService css;

	/**
	 * 通过名称获得代码名称
	 * 
	 * @param tag
	 * @param value
	 * @return
	 */
	public String getCodeNameByValue(TagElementType tag, String value) {
		try {
			if (tag != null && !Const.isEmpty(tag.getCodeSetId())
					&& !Const.isEmpty(value)) {
				return css.getCodeNameByValue(tag.getCodeSetId(), value);
			}
		} catch (Exception e) {
			log.error("通过名称获得代码名称出现错误。");
		}
		return value;
	}
}
